package com.readbook.service;

import com.readbook.dao.PoetryreadDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class PoetryreadService {
    @Autowired
    private PoetryreadDao poetryreadDao;


    public int savePoteryRead(Map<String,Object>gmap)
    {
        return poetryreadDao.savePoteryRead(gmap);
    }


    public int editPoteryRead(Map<String,Object>gmap)
    {
        return poetryreadDao.editPoteryRead(gmap);
    }


    public List<Map<String,Object>>getPoetryread(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=poetryreadDao.getPoetryread(gmap);
        return list1;
    }


    public int countPoetryread(Map<String,Object>gmap)
    {
        return poetryreadDao.countPoetryread(gmap);
    }

    public List<Map<String,Object>>getHomeWork(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=new ArrayList<>();
        //查询当天的诗词作业检查任务
        List<Map<String,Object>>works=poetryreadDao.getTodayHomeWork(gmap);
        //查询诗词前十条
        for(int i=0;i<works.size();i++){
            Map<String,Object>wmaps=works.get(i);
            String readid=wmaps.get("READID").toString();
            gmap.put("readid",readid);
            List<Map<String,Object>>mywork=poetryreadDao.getHomeWork(gmap);
            for(int j=0;j<mywork.size();j++){
                list1.add(mywork.get(j));
            }
        }
        return list1;
    }

    public List<Map<String,Object>>search_poetryread(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=poetryreadDao.search_poetryread(gmap);
        return list1;
    }



    public int del_poetryreadscore(Map<String,Object>gmap)
    {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        gmap.put("jlscsj",df.format(new Date()));
        gmap.put("jlsczt","1");
        return poetryreadDao.del_poetryreadscore(gmap);
    }

    public List<Map<String,Object>>getAllPoetryRead()
    {
        List<Map<String,Object>>list1=poetryreadDao.getAllPoetryRead();
        return list1;
    }



    public int add_poetryreadscore(Map<String,Object>gmap)
    {
        return poetryreadDao.add_poetryreadscore(gmap);
    }





    public int edit_poetryreadscore(Map<String,Object>gmap)
    {
        return poetryreadDao.add_poetryreadscore(gmap);
    }




    public Map<String,Object>getPoetryReadById(Map<String,Object>gmap)
    {
        Map<String,Object>rmap=new HashMap<>();
        rmap=poetryreadDao.getPoetryReadById(gmap);
        //查询诗词内容
        List<Map<String,Object>>listsc=poetryreadDao.getPoetryReadScnrById(gmap);
        for(int m=0;m<listsc.size();m++){
            Map<String,Object>getmap=listsc.get(m);
            getmap.put("imgtype",0);
        }

        //查询诗词语音
        List<Map<String,Object>>listyy=poetryreadDao.getPoetryReadYpById(gmap);
        for(int i=0;i<listyy.size();i++){
            Map<String,Object>getmap=listyy.get(i);
            getmap.put("playStatus",true);
            getmap.put("playtype",0);
        }
        rmap.put("scnr",listsc);
        rmap.put("yy",listyy);
        return rmap;
    }




    public List<Map<String,Object>>getAllHomeworkByreadid(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=poetryreadDao.getAllHomeworkByreadid(gmap);
        return list1;
    }


    public int countAllHomeworkByreadid(Map<String,Object>gmap)
    {
        return poetryreadDao.countAllHomeworkByreadid(gmap);
    }



    public List<Map<String,Object>>getHomeworkPmByreadid(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=poetryreadDao.getHomeworkPmByreadid(gmap);
        return list1;
    }


    public int countHomeworkPmByreadid(Map<String,Object>gmap)
    {
        return poetryreadDao.countHomeworkPmByreadid(gmap);
    }



    public int savePoteryReadLog(Map<String,Object>gmap)
    {
        return poetryreadDao.savePoteryReadLog(gmap);
    }



    public int setPoetryreadlogStar(Map<String,Object>gmap)
    {
        return poetryreadDao.setPoetryreadlogStar(gmap);
    }

    /**
     * @author 牟明艳
     * @comments  提交诗词音频文件
     * @time 2019-10-30 16:06:56
     */
    public int savePoetryreadYp(Map<String,Object>gmap)
    {
        return poetryreadDao.savePoetryreadYp(gmap);
    }



    /**
     * @author 牟明艳
     * @comments  提交诗词内容图片
     * @time 2019-10-30 16:06:56
     */
    public int savePicture(Map<String,Object>gmap)
    {
        return poetryreadDao.savePicture(gmap);
    }



    public int delPoetryreadYp(Map<String,Object>gmap)
    {
        return poetryreadDao.delPoetryreadYp(gmap);
    }


    public int delScPicture(Map<String,Object>gmap)
    {
        return poetryreadDao.delScPicture(gmap);
    }


}


